<template>
  <a-form-model
      ref="ruleForm"
      :model="form"
      :rules="rules"
  >
    <a-form-model-item ref="name" label="Activity name" prop="name">
      <a-input
          v-model="form.name"
          @blur="
          () => {
            $refs.name.onFieldBlur();
          }
        "
      />
    </a-form-model-item>
    <a-form-model-item>
      <a-button type="primary" @click="resetForm">创建</a-button>
    </a-form-model-item>
  </a-form-model>

</template>
<script>
export default {
  data() {
    return {
      form: {
        name: '',
      },
      rules: {
        name: [
          { required: true, message: 'Please input Activity name', trigger: 'blur' },
          { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
        ],
      }
    };
  },
  methods: {
    onSubmit() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm() {
      console.log(this.$refs);
      this.$refs.ruleForm.resetFields();
    },
  },
};
</script>
